package com.example.idachuappone.index.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.idachuappone.R;
import com.example.idachuappone.index.entity.FamilyFeast;
import com.lidroid.xutils.BitmapUtils;
import java.util.List;

public class AdapterFamilyFeast extends BaseAdapter {
    private BitmapUtils bu;
    private Context context;
    private List<FamilyFeast> list;

    private class ViewHolder {
        private ImageView img_head;
        private TextView tv_name;
        private TextView tv_slogan;

        private ViewHolder() {
        }
    }

    public void setList(List<FamilyFeast> list) {
        this.list = list;
    }

    public AdapterFamilyFeast(Context context, BitmapUtils bu) {
        this.context = context;
        this.bu = bu;
    }

    public int getCount() {
        return this.list == null ? 0 : this.list.size();
    }

    public Object getItem(int position) {
        return this.list == null ? null : (FamilyFeast) this.list.get(position);
    }

    public long getItemId(int position) {
        return (long) position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LinearLayout.inflate(this.context, R.layout.simple_family_feast_item, null);
            holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            holder.tv_slogan = (TextView) convertView.findViewById(R.id.tv_slogan);
            holder.img_head = (ImageView) convertView.findViewById(R.id.img_head);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        FamilyFeast familyFeast = (FamilyFeast) this.list.get(position);
        holder.tv_name.setText(familyFeast.getName());
        holder.tv_slogan.setText(familyFeast.getSlogan());
        this.bu.display(holder.img_head, familyFeast.getHead());
        return convertView;
    }
}
